package com.example.base.utils

import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Interceptor
import com.alibaba.android.arouter.facade.callback.InterceptorCallback
import com.alibaba.android.arouter.facade.template.IInterceptor
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.SPUtils

/**
 * 登录拦截
 */
@Interceptor(priority = 1)
class LoginInterceptor:IInterceptor {
    override fun init(context: Context?) {

    }

    override fun process(postcard: Postcard?, callback: InterceptorCallback?) {
        //进行拦截操作
        if("/userinfo/LoginActivity".equals(postcard?.path)||SPUtils.getInstance().getString("token").isNotEmpty()){
            callback?.onContinue(postcard)
        }else{
            ARouter.getInstance().build("/userinfo/LoginActivity").navigation()
        }
    }
}